<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Email extends Controller
{
	function __construct()
	{
        parent::Controller();
        $this->auth->CheckTaMeR(101);
        $this->setVars();
	}
    
	function setVars()
	{
        define('URI', $this->uri->segment(1).'/'.$this->uri->segment(2));
        define('URL', site_url(URI).'/');
//        define('GETURL',site_url(URI).'/');

		$this->tpl['head'] = '';
		$this->tpl['title'] = 'Tes email sending';
	    $this->tpl['body'] = '';
        
        $this->tpl['link'] = anchor(URI.'/form', 'Form').' | ';
        $this->tpl['link'] .= anchor(URI.'/save', 'Save');
	}
    
    /**
     * @note	index
     * @info	redirect
     * @author	Dennis T. Kaplan
     * @access	public
     * @param	 
     * @return	
     */	
	function index()
	{
        $this->tpl['body'] .= '<img src="/img/truckbunner.gif"/>';

        //$this->ActivationEmail('gruessle@gmail.com', 'mypasshaha');
		$this->load->view('blank', $this->tpl);
	}

    

	function test1()
	{
        $this->tpl['body'] .= '<img src="/img/truckbunner.gif"/>';

        $this->load->library('email');
    
        $this->email->from('NoReply@PzzAzz.com', 'Account Activation');
        $this->email->to('gruessle@gmail.com');
        $this->email->subject('Email Test');
        $link = '{unwrap}http://www.some-site.com/a_long_link_that_should_not_be_wrapped.html{/unwrap}';
        $this->email->message('Testing the email class this is a long text to be wraped followed by no wrap If you prefer not to set preferences using the above method, you can instead put them into a config fileIf you prefer not to set preferences using the above method, you can instead put them into a config file. '.$link);
        $this->email->attach(BASEPATH.'../img/logo.gif');
        //$this->email->send();


        $this->tpl['body'] .= $this->email->print_debugger();
		$this->load->view('blank', $this->tpl);
	}


    private function ActivationEmail($email, $password)
    {
        $this->load->library('email');

        $this->email->from('NoReply@PzzAzz.com', 'PzzAzz Auto Support');
        $this->email->to($email);
        
        $this->email->subject('PzzAzz Account Activaten.');
        $host = $_SERVER['HTTP_HOST'];
        $message = 'Welcome to PzzAzz Mobile Billboard Advertising.';
        $message .= "\r\n\r\n";
        $message .= 'Your assigned password: '.$password;
        $message .= "\r\n\r\n";
        $message .= 'If you have received this mail in error you do not need to take any action to cancel the account. The account and all the information will be deleted from our server periodically, if no one logs and you will not receive any further emails.';
        $message .= "\r\n\r\n";
        $message .= "Thank you for using $host";
        $message .= "\r\n\r\n";
        $message .= "This is a post-only mailing, replies to this email are not monitored or answered.";
        $message .= "\r\n";
        $message .= "We take your privacy serious, please report abuse to support at $host";

        $this->email->message($message);
        $this->email->attach(BASEPATH.'../img/logo.gif');
        $this->email->send();
        $this->tpl['body'] .= $this->email->print_debugger();
    }

    
}
?>
